// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyViewAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyViewAttributes
//
// Purpose:
//   This class contains the view attributes.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a ViewAttributes.
//
struct ViewAttributesObject
{
    PyObject_HEAD
    ViewAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewViewAttributes(int);
std::string
PyViewAttributes_ToString(const ViewAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    {   const double *viewNormal = atts->GetViewNormal();
        snprintf(tmpStr, 1000, "%sviewNormal = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", viewNormal[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *focus = atts->GetFocus();
        snprintf(tmpStr, 1000, "%sfocus = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", focus[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *viewUp = atts->GetViewUp();
        snprintf(tmpStr, 1000, "%sviewUp = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", viewUp[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%sviewAngle = %g\n", prefix, atts->GetViewAngle());
    str += tmpStr;
    if(atts->GetSetScale())
        snprintf(tmpStr, 1000, "%ssetScale = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%ssetScale = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sparallelScale = %g\n", prefix, atts->GetParallelScale());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%snearPlane = %g\n", prefix, atts->GetNearPlane());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sfarPlane = %g\n", prefix, atts->GetFarPlane());
    str += tmpStr;
    {   const double *imagePan = atts->GetImagePan();
        snprintf(tmpStr, 1000, "%simagePan = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 2; ++i)
        {
            snprintf(tmpStr, 1000, "%g", imagePan[i]);
            str += tmpStr;
            if(i < 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%simageZoom = %g\n", prefix, atts->GetImageZoom());
    str += tmpStr;
    if(atts->GetPerspective())
        snprintf(tmpStr, 1000, "%sperspective = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sperspective = 0\n", prefix);
    str += tmpStr;
    {   const double *windowCoords = atts->GetWindowCoords();
        snprintf(tmpStr, 1000, "%swindowCoords = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 4; ++i)
        {
            snprintf(tmpStr, 1000, "%g", windowCoords[i]);
            str += tmpStr;
            if(i < 3)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const double *viewportCoords = atts->GetViewportCoords();
        snprintf(tmpStr, 1000, "%sviewportCoords = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 4; ++i)
        {
            snprintf(tmpStr, 1000, "%g", viewportCoords[i]);
            str += tmpStr;
            if(i < 3)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%seyeAngle = %g\n", prefix, atts->GetEyeAngle());
    str += tmpStr;
    return str;
}

static PyObject *
ViewAttributes_Notify(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_SetViewNormal(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetViewNormal();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the viewNormal in the object as modified.
    obj->data->SelectViewNormal();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetViewNormal(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the viewNormal.
    PyObject *retval = PyTuple_New(3);
    const double *viewNormal = obj->data->GetViewNormal();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(viewNormal[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetFocus(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetFocus();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the focus in the object as modified.
    obj->data->SelectFocus();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetFocus(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the focus.
    PyObject *retval = PyTuple_New(3);
    const double *focus = obj->data->GetFocus();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(focus[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetViewUp(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetViewUp();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the viewUp in the object as modified.
    obj->data->SelectViewUp();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetViewUp(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the viewUp.
    PyObject *retval = PyTuple_New(3);
    const double *viewUp = obj->data->GetViewUp();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(viewUp[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetViewAngle(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the viewAngle in the object.
    obj->data->SetViewAngle(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetViewAngle(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetViewAngle());
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetSetScale(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the setScale in the object.
    obj->data->SetSetScale(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetSetScale(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetSetScale()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetParallelScale(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the parallelScale in the object.
    obj->data->SetParallelScale(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetParallelScale(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetParallelScale());
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetNearPlane(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the nearPlane in the object.
    obj->data->SetNearPlane(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetNearPlane(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetNearPlane());
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetFarPlane(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the farPlane in the object.
    obj->data->SetFarPlane(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetFarPlane(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetFarPlane());
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetImagePan(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetImagePan();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 2)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 2)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 2 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the imagePan in the object as modified.
    obj->data->SelectImagePan();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetImagePan(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the imagePan.
    PyObject *retval = PyTuple_New(2);
    const double *imagePan = obj->data->GetImagePan();
    for(int i = 0; i < 2; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(imagePan[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetImageZoom(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the imageZoom in the object.
    obj->data->SetImageZoom(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetImageZoom(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetImageZoom());
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetPerspective(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the perspective in the object.
    obj->data->SetPerspective(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetPerspective(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPerspective()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetWindowCoords(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetWindowCoords();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 4)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 4)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 4 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the windowCoords in the object as modified.
    obj->data->SelectWindowCoords();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetWindowCoords(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the windowCoords.
    PyObject *retval = PyTuple_New(4);
    const double *windowCoords = obj->data->GetWindowCoords();
    for(int i = 0; i < 4; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(windowCoords[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetViewportCoords(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetViewportCoords();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 4)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 4)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 4 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the viewportCoords in the object as modified.
    obj->data->SelectViewportCoords();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetViewportCoords(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the viewportCoords.
    PyObject *retval = PyTuple_New(4);
    const double *viewportCoords = obj->data->GetViewportCoords();
    for(int i = 0; i < 4; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(viewportCoords[i]));
    return retval;
}

/*static*/ PyObject *
ViewAttributes_SetEyeAngle(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the eyeAngle in the object.
    obj->data->SetEyeAngle(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ViewAttributes_GetEyeAngle(PyObject *self, PyObject *args)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetEyeAngle());
    return retval;
}



PyMethodDef PyViewAttributes_methods[VIEWATTRIBUTES_NMETH] = {
    {"Notify", ViewAttributes_Notify, METH_VARARGS},
    {"SetViewNormal", ViewAttributes_SetViewNormal, METH_VARARGS},
    {"GetViewNormal", ViewAttributes_GetViewNormal, METH_VARARGS},
    {"SetFocus", ViewAttributes_SetFocus, METH_VARARGS},
    {"GetFocus", ViewAttributes_GetFocus, METH_VARARGS},
    {"SetViewUp", ViewAttributes_SetViewUp, METH_VARARGS},
    {"GetViewUp", ViewAttributes_GetViewUp, METH_VARARGS},
    {"SetViewAngle", ViewAttributes_SetViewAngle, METH_VARARGS},
    {"GetViewAngle", ViewAttributes_GetViewAngle, METH_VARARGS},
    {"SetSetScale", ViewAttributes_SetSetScale, METH_VARARGS},
    {"GetSetScale", ViewAttributes_GetSetScale, METH_VARARGS},
    {"SetParallelScale", ViewAttributes_SetParallelScale, METH_VARARGS},
    {"GetParallelScale", ViewAttributes_GetParallelScale, METH_VARARGS},
    {"SetNearPlane", ViewAttributes_SetNearPlane, METH_VARARGS},
    {"GetNearPlane", ViewAttributes_GetNearPlane, METH_VARARGS},
    {"SetFarPlane", ViewAttributes_SetFarPlane, METH_VARARGS},
    {"GetFarPlane", ViewAttributes_GetFarPlane, METH_VARARGS},
    {"SetImagePan", ViewAttributes_SetImagePan, METH_VARARGS},
    {"GetImagePan", ViewAttributes_GetImagePan, METH_VARARGS},
    {"SetImageZoom", ViewAttributes_SetImageZoom, METH_VARARGS},
    {"GetImageZoom", ViewAttributes_GetImageZoom, METH_VARARGS},
    {"SetPerspective", ViewAttributes_SetPerspective, METH_VARARGS},
    {"GetPerspective", ViewAttributes_GetPerspective, METH_VARARGS},
    {"SetWindowCoords", ViewAttributes_SetWindowCoords, METH_VARARGS},
    {"GetWindowCoords", ViewAttributes_GetWindowCoords, METH_VARARGS},
    {"SetViewportCoords", ViewAttributes_SetViewportCoords, METH_VARARGS},
    {"GetViewportCoords", ViewAttributes_GetViewportCoords, METH_VARARGS},
    {"SetEyeAngle", ViewAttributes_SetEyeAngle, METH_VARARGS},
    {"GetEyeAngle", ViewAttributes_GetEyeAngle, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
ViewAttributes_dealloc(PyObject *v)
{
   ViewAttributesObject *obj = (ViewAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *ViewAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyViewAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "viewNormal") == 0)
        return ViewAttributes_GetViewNormal(self, NULL);
    if(strcmp(name, "focus") == 0)
        return ViewAttributes_GetFocus(self, NULL);
    if(strcmp(name, "viewUp") == 0)
        return ViewAttributes_GetViewUp(self, NULL);
    if(strcmp(name, "viewAngle") == 0)
        return ViewAttributes_GetViewAngle(self, NULL);
    if(strcmp(name, "setScale") == 0)
        return ViewAttributes_GetSetScale(self, NULL);
    if(strcmp(name, "parallelScale") == 0)
        return ViewAttributes_GetParallelScale(self, NULL);
    if(strcmp(name, "nearPlane") == 0)
        return ViewAttributes_GetNearPlane(self, NULL);
    if(strcmp(name, "farPlane") == 0)
        return ViewAttributes_GetFarPlane(self, NULL);
    if(strcmp(name, "imagePan") == 0)
        return ViewAttributes_GetImagePan(self, NULL);
    if(strcmp(name, "imageZoom") == 0)
        return ViewAttributes_GetImageZoom(self, NULL);
    if(strcmp(name, "perspective") == 0)
        return ViewAttributes_GetPerspective(self, NULL);
    if(strcmp(name, "windowCoords") == 0)
        return ViewAttributes_GetWindowCoords(self, NULL);
    if(strcmp(name, "viewportCoords") == 0)
        return ViewAttributes_GetViewportCoords(self, NULL);
    if(strcmp(name, "eyeAngle") == 0)
        return ViewAttributes_GetEyeAngle(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyViewAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyViewAttributes_methods[i].ml_name),
                PyString_FromString(PyViewAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyViewAttributes_methods, self, name);
}

int
PyViewAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "viewNormal") == 0)
        obj = ViewAttributes_SetViewNormal(self, args);
    else if(strcmp(name, "focus") == 0)
        obj = ViewAttributes_SetFocus(self, args);
    else if(strcmp(name, "viewUp") == 0)
        obj = ViewAttributes_SetViewUp(self, args);
    else if(strcmp(name, "viewAngle") == 0)
        obj = ViewAttributes_SetViewAngle(self, args);
    else if(strcmp(name, "setScale") == 0)
        obj = ViewAttributes_SetSetScale(self, args);
    else if(strcmp(name, "parallelScale") == 0)
        obj = ViewAttributes_SetParallelScale(self, args);
    else if(strcmp(name, "nearPlane") == 0)
        obj = ViewAttributes_SetNearPlane(self, args);
    else if(strcmp(name, "farPlane") == 0)
        obj = ViewAttributes_SetFarPlane(self, args);
    else if(strcmp(name, "imagePan") == 0)
        obj = ViewAttributes_SetImagePan(self, args);
    else if(strcmp(name, "imageZoom") == 0)
        obj = ViewAttributes_SetImageZoom(self, args);
    else if(strcmp(name, "perspective") == 0)
        obj = ViewAttributes_SetPerspective(self, args);
    else if(strcmp(name, "windowCoords") == 0)
        obj = ViewAttributes_SetWindowCoords(self, args);
    else if(strcmp(name, "viewportCoords") == 0)
        obj = ViewAttributes_SetViewportCoords(self, args);
    else if(strcmp(name, "eyeAngle") == 0)
        obj = ViewAttributes_SetEyeAngle(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
ViewAttributes_print(PyObject *v, FILE *fp, int flags)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)v;
    fprintf(fp, "%s", PyViewAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
ViewAttributes_str(PyObject *v)
{
    ViewAttributesObject *obj = (ViewAttributesObject *)v;
    return PyString_FromString(PyViewAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *ViewAttributes_Purpose = "This class contains the view attributes.";
#else
static char *ViewAttributes_Purpose = "This class contains the view attributes.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(ViewAttributesType,         \
                  "ViewAttributes",           \
                  ViewAttributesObject,       \
                  ViewAttributes_dealloc,     \
                  ViewAttributes_print,       \
                  PyViewAttributes_getattr,   \
                  PyViewAttributes_setattr,   \
                  ViewAttributes_str,         \
                  ViewAttributes_Purpose,     \
                  ViewAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
ViewAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &ViewAttributesType
         || Py_TYPE(other) != &ViewAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    ViewAttributes *a = ((ViewAttributesObject *)self)->data;
    ViewAttributes *b = ((ViewAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static ViewAttributes *defaultAtts = 0;
static ViewAttributes *currentAtts = 0;

static PyObject *
NewViewAttributes(int useCurrent)
{
    ViewAttributesObject *newObject;
    newObject = PyObject_NEW(ViewAttributesObject, &ViewAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ViewAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ViewAttributes(*defaultAtts);
    else
        newObject->data = new ViewAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapViewAttributes(const ViewAttributes *attr)
{
    ViewAttributesObject *newObject;
    newObject = PyObject_NEW(ViewAttributesObject, &ViewAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (ViewAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
ViewAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewViewAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef ViewAttributesMethods[] = {
    {"ViewAttributes", ViewAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *ViewAttributesObserver = 0;

std::string
PyViewAttributes_GetLogString()
{
    std::string s("ViewAtts = ViewAttributes()\n");
    if(currentAtts != 0)
        s += PyViewAttributes_ToString(currentAtts, "ViewAtts.", true);
    return s;
}

static void
PyViewAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("ViewAtts = ViewAttributes()\n");
        s += PyViewAttributes_ToString(currentAtts, "ViewAtts.", true);
        cb(s);
    }
}

void
PyViewAttributes_StartUp(ViewAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyViewAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(ViewAttributesObserver == 0)
    {
        ViewAttributesObserver = new ObserverToCallback(subj,
            PyViewAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyViewAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete ViewAttributesObserver;
    ViewAttributesObserver = 0;
}

PyMethodDef *
PyViewAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return ViewAttributesMethods;
}

bool
PyViewAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &ViewAttributesType);
}

ViewAttributes *
PyViewAttributes_FromPyObject(PyObject *obj)
{
    ViewAttributesObject *obj2 = (ViewAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyViewAttributes_New()
{
    return NewViewAttributes(0);
}

PyObject *
PyViewAttributes_Wrap(const ViewAttributes *attr)
{
    return WrapViewAttributes(attr);
}

void
PyViewAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    ViewAttributesObject *obj2 = (ViewAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyViewAttributes_SetDefaults(const ViewAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new ViewAttributes(*atts);
}

